#ifndef OBJLOADER_H
#define OBJLOADER_H

#include "bga/system/Loader.h"
#include "bga/system/Tuple.h"
#include <string>

#include "bga/graphics/SceneNode.h"

/**
 * \namespace bga
 * \brief API namespace
 */
namespace bga
{

/*!
 * \class OBJLoader
 * \brief this class is a loader for obj file
 *
 *
 */
class BOARD_HELL_ENGINE OBJLoader : public Loader<Drawable>
{

    typedef Tuple<3, float> OBJTripletFloat;
    typedef Tuple<2, float> OBJDoubletFloat;
    typedef Tuple<3, unsigned short> OBJTripletUS;


	public:
		OBJLoader();    ///!< Constructor
		virtual ~OBJLoader();   ///!< Destructor

        virtual Drawable* load(File& file);

        /**
         * \brief load the OBJ file
         * \param filename : name of the file to read
         */
		virtual void load(const std::string& filename);

		/**
		 * \brief get the drawable associated to OBJ imported
		 * \param drawable : drawable object to fill
		 */
		virtual void getDrawable(Drawable& drawable);

		/**
		 * \brief get the texture associated to OBJ imported
		 * \param texture : texture object to fill
		 */
        virtual void getTexture(Texture2D& texture);

        /**
		 * \brief get the scene node associated to OBJ imported
		 * \param sceneNode : scene node object to fill
		 */
        virtual void setSceneNode(SceneNode& sceneNode);

	private:

        /**
         * \brief parse and get the three differents indices from the OBJ file : vertex index, texture coordinates, normal index
         * \param s : string to parse
         */
        OBJTripletUS getIndices(const std::string& s);

        std::vector<OBJTripletFloat> listVertex;      ///!< list of vertex coordinates
        std::vector<OBJDoubletFloat> listTexCoord;    ///!< list of vertex texture coordiantes
        std::vector<OBJTripletFloat> listNormals;     ///!< list of vertex normal
        std::vector<OBJTripletUS> listIndices;        ///!< list of indices



};


}

#endif // OBJLOADER_H


